package org.yankun.exam4j.web.view;

import java.util.Map;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.servlet.view.freemarker.FreeMarkerView;
import org.yankun.exam4j.session.SessionManager;
import org.yankun.exam4j.session.UserSessionData;

public class Exam4jFreeMarkerView extends FreeMarkerView {
	
	public Exam4jFreeMarkerView() {
		super();
	}
	
	@Override
	protected void exposeHelpers(Map<String,Object> model, HttpServletRequest request) throws Exception {
		super.exposeHelpers(model,request);
		String path=request.getContextPath();
		
		model.put("basePath",path);
		
		UserSessionData userSessionData=SessionManager.getSessionData(request.getSession());
		// TODO 添加自定义的 EL 变量 
		//request.setAttribute("testMessage", "如果看到这个就说明成功");
		if (userSessionData != null)
			request.setAttribute("userData", userSessionData);
		
		Properties systemProperties = System.getProperties();
		request.setAttribute("systemProperties", systemProperties);
	}
	
}
